package com.ruoyi.system.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.system.api.domain.SysUserEdu;
import com.ruoyi.system.service.ISysUserEduService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户教育信息
 *
 * @author ruoyi
 */
@Api(tags = "用户教育信息")
@RestController
@RequestMapping("/user/edu")
public class SysUserEduController extends BaseController {

    @Autowired
    private ISysUserEduService sysUserEduService;

    /**
     * 获取用户教育经历列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取用户教育经历列表", response = SysUserEdu.class)
    public AjaxResult list(SysUserEdu sysUserEdu) {
        List<SysUserEdu> list = sysUserEduService.selectUserEduList(sysUserEdu);
        return success(list);
    }

    /**
     * * 详情接口
     *
     * @param eduId
     * @return
     */
    @GetMapping("/{eduId}")
    @ApiOperation(value = "详情接口", response = SysUserEdu.class)
    public AjaxResult getInfo(@ApiParam(value = "用户教育id", required = true) @PathVariable Long eduId) {
        return success(sysUserEduService.selectUserEduByEduId(eduId));
    }

    /**
     * 新增用户教育经历
     */
    @Log(title = "新增用户教育经历", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增用户教育经历")
    public AjaxResult add(@RequestBody SysUserEdu sysUserEdu) {
        return success(sysUserEduService.insertEdu(sysUserEdu));
    }

    /**
     * 删除用户教育经历
     */
    @Log(title = "删除用户教育经历", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete/{eduIds}")
    @ApiOperation("删除用户教育经历")
    public AjaxResult remove(@ApiParam(value = "教育id", required = true) @PathVariable Long[] eduIds) {
        return toAjax(sysUserEduService.deleteSysUserEduByEduIds(eduIds));
    }
}
